package com.seven.demo.java8;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 常用流操作
 * @author Administrator
 *
 */
public class Test2 {

	public static void main(String[] args) {
		Test2 t2 = new Test2();
		t2.collect();
	}
	
	/**
	 * collect(toList()) 方法由 Stream 里的值生成一个列表， 是一个及早求值操作
	 */
	public void collect() {
		List<Integer> lists = Stream.of(1,2,3,4).collect(Collectors.toList());
		System.out.println(lists);
		lists.remove(1);
		List<Integer> lists2 = Arrays.asList(1,2,3,4);
		System.out.println(lists2);
		int i = lists2.set(3, 5);
		System.out.println(i);
		System.out.println(lists2);
	}
}
